package com.jingjiu.homeservicesbiz.controller;

import java.util.List;

import com.jingjiu.homeservicesapi.domain.DiseaseInfo;
import com.jingjiu.homeservicesbiz.service.IDiseaseInfoService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 疾病信息：用于存储具体疾病的介绍与科普内容Controller
 * 
 * @author ruoyi
 * @date 2025-04-16
 */
@RestController
@RequestMapping("disease/system/info")
public class DiseaseInfoController extends BaseController
{

    @Autowired
    private IDiseaseInfoService diseaseInfoService;



    /**
     * 查询疾病信息：用于存储具体疾病的介绍与科普内容列表
     */
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(DiseaseInfo diseaseInfo)
    {
        startPage();
        List<DiseaseInfo> list = diseaseInfoService.selectDiseaseInfoList(diseaseInfo);
        return getDataTable(list);
    }

    /**
     * 导出疾病信息：用于存储具体疾病的介绍与科普内容列表
     */
    @Log(title = "疾病信息：用于存储具体疾病的介绍与科普内容", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(@RequestBody DiseaseInfo diseaseInfo)
    {
        List<DiseaseInfo> list = diseaseInfoService.selectDiseaseInfoList(diseaseInfo);
        ExcelUtil<DiseaseInfo> util = new ExcelUtil<DiseaseInfo>(DiseaseInfo.class);
        return util.exportExcel(list, "疾病信息：用于存储具体疾病的介绍与科普内容数据");
    }



    /**
     * 新增保存疾病信息：用于存储具体疾病的介绍与科普内容
     */
    @RequiresPermissions("system:info:add")
    @Log(title = "疾病信息：用于存储具体疾病的介绍与科普内容", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(@RequestBody DiseaseInfo diseaseInfo)
    {
        return toAjax(diseaseInfoService.insertDiseaseInfo(diseaseInfo));
    }

    /**
     * 修改疾病信息：用于存储具体疾病的介绍与科普内容
     */
    @RequiresPermissions("system:info:edit")
    @GetMapping("/get/{id}")
    public DiseaseInfo getById(@PathVariable("id") Long id)
    {
        DiseaseInfo diseaseInfo = diseaseInfoService.selectDiseaseInfoById(id);
        return diseaseInfo;
    }

    /**
     * 修改保存疾病信息：用于存储具体疾病的介绍与科普内容
     */
    @RequiresPermissions("system:info:edit")
    @Log(title = "疾病信息：用于存储具体疾病的介绍与科普内容", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(@RequestBody DiseaseInfo diseaseInfo)
    {
        return toAjax(diseaseInfoService.updateDiseaseInfo(diseaseInfo));
    }

    /**
     * 删除疾病信息：用于存储具体疾病的介绍与科普内容
     */
    @RequiresPermissions("system:info:remove")
    @Log(title = "疾病信息：用于存储具体疾病的介绍与科普内容", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(diseaseInfoService.deleteDiseaseInfoByIds(ids));
    }
}
